﻿@inject IDataCacheService _dataCacheService
@inject NavigationManager NavigationManager

@if (Model.MainState == EditState.Preview)
{
    <CnGalWebSite.Shared.MasaComponent.Shared.Editors.Buttons.RevokeButton Url="@("/space/EditMain/EditSpaceFavoriteObjects?FolderId=" + Model.Id)" ExamineType="Operation.EditFavoriteFolderMain" OnClickRevoke="OnRevoke" Class="ms-4 me-4" />
}
<CnGalWebSite.Shared.MasaComponent.Shared.MaterialDesigns.MDMainInfoCard Name="@Model.Name" Image="@Model.MainPicture"
                                                                         BriefIntroduction="@Model.BriefIntroduction" Small="ForceSmall">
    <ButtonContent>
        @if (HiddenButton == false)
        {
            <CnGalWebSite.Components.Containers.MiniModeContainer>
                <div class="mt-2" style="@("display: flex; "+(ForceSmall||_dataCacheService.IsApp?"justify-content: center;":"justify-content: flex-end;"))">
                    @if (Model.Authority)
                    {
                        <CnGalWebSite.Components.Buttons.MasaButton Fab Icon="mdi-pencil" Tooltip="编辑" OnClick="@(() =>  NavigationManager.NavigateTo("/space/EditSpaceFavoriteObjects?FolderId="+Model.Id))" />
                    }

                    @if (ToolHelper.IsMaui)
                    {
                        <CnGalWebSite.Shared.MasaComponent.Shared.Buttons.ShareButton Title="@("目录 - "+Model.Name)" Class="ms-4" Text="@($"《{Model.Name}》\n{Model.BriefIntroduction}")" />
                    }
                </div>
            </CnGalWebSite.Components.Containers.MiniModeContainer>

        }
    </ButtonContent>
</CnGalWebSite.Shared.MasaComponent.Shared.MaterialDesigns.MDMainInfoCard>
@code {
    [Parameter]
    public FavoriteFolderViewModel Model { get; set; }
    [Parameter]
    public bool HiddenButton { get; set; }
    [Parameter]
    public bool ForceSmall { get; set; }

    [Parameter]
    public EventCallback<Operation> OnRevoke { get; set; }
    [Parameter]
    public EventCallback<bool> OnPreEdit { get; set; }
}
